#include<bits/stdc++.h>
using namespace std;
#define pll pair<int,int>
#define int long long
const int N=1e5+10;
const int M=1e5+10;
const double eps=1e-7;
int read(){
    int res=0,f=1;
    char ch=getchar();
    while(ch<'0'||ch>'9'){
        if(ch=='-') f=-1;
        ch=getchar();
    }
    while(ch>='0'&&ch<='9'){
        res=res*10+ch-'0';
        ch=getchar();
    }
    return res*f;
}
int T;
int n,m,L,V;
int d[N],v[N],a[N];
int p[M];
int cl[N],cr[N];
vector<pll> clr;
int maxx=0,mid;
bool cmp(pll a,pll b){
    if(a.second!=b.second) return a.second<b.second;
    return a.first<b.first;
}
bool f1,f2;
int cnt1;
signed main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    T=read();
    while(T--){
        maxx=0;
        f1=f2=cnt1=0;
        clr.clear();
        n=read();
        m=read();
        L=read();
        V=read();
        for(int i=1;i<=n;i++){
            d[i]=read();
            v[i]=read();
            a[i]=read();
            if(a[i]<0) f1=f2=1;
            if(a[i]==0) f1=1; 
        }
        for(int i=1;i<=m;i++) p[i]=read();
        for(int i=1;i<=n;i++){
            if(a[i]>0){
                if(v[i]<=V) {cl[i]=(int)ceil((double)(V*V-v[i]*v[i])/(2*a[i])+d[i]);if(cl[i]<p[m]||(double)((V*V-v[i]*v[i])/(2*a[i])+d[i])<p[m]) cnt1++;}
                else {cl[i]=d[i];if(d[i]<=p[m]) cnt1++;}
                cr[i]=L;
                if(cl[i]>maxx){
                    maxx=cl[i];
                    mid=i;
                }
            }
            else if(a[i]==0){
                if(v[i]<=V) cl[i]=cr[i]=L+1;
                else{
                    cnt1++;
                    cl[i]=d[i];
                    cr[i]=L;
                    if(cl[i]>maxx) maxx=cl[i],mid=i;
                }
            }
            else{
                if(v[i]<=V) cl[i]=cr[i]=L+1;
                else{
                    cl[i]=d[i];
                    cr[i]=(int)floor((double)(V*V-v[i]*v[i])/(2*a[i])+d[i]);
                    //if(abs((double)(V*V-v[i]*v[i])/(2*a[i])+d[i]-cr[i])<=eps) cr[i]-=1;
                    //printf("%lld\n",(int)((double)(V*V-v[i]*v[i])/(2*a[i])));
                    if(cr[i]>=L){
                        if(cl[i]>maxx) maxx=cl[i],mid=i;
                    }
                }
            }
        }
        //printf("%lld\n",maxx);
        //for(int i=1;i<=n;i++) printf("%lld %lld\n",cl[i],cr[i]);
        if(!f1){
            printf("%lld ",cnt1);
            if(cnt1>0) printf("%lld\n",m-1);
            else printf("%lld\n",m);
            continue;
        }
        else if(!f2){
            printf("%lld ",cnt1);
            if(cnt1>0) printf("%lld\n",m-1);
            else printf("%lld\n",m);
            continue;
        }
        int ans1=0;
        for(int i=1;i<=n;i++){
            int t1=lower_bound(p+1,p+1+m,cl[i])-(p+1);
            int t2=upper_bound(p+1,p+1+m,cr[i])-(p+1);
            //printf("%lld %lld %lld %lld %lld\n",i,cl[i],cr[i],t1,t2);
            if(t1<t2){

                ans1++;
                if(cr[i]<L) {
                    if(cl[i]-p[t1]>0) t1++;
                    if(p[t2]-cr[i]>0) t2--;
                    clr.push_back(make_pair(t1,t2));
                }
            }
        }
        bool f=0;
        if(maxx!=0){
            for(int i=1;i<=m;i++){
                if(cl[mid]<=p[i]){
                    clr.push_back(make_pair(i,m));
                    f=1;
                    break;
                }
            }
            if(!f) clr.push_back(make_pair(m,m));
        }
        //for(int i=0;i<clr.size();i++){
        //    printf("%lld %lld1\n",clr[i].first,clr[i].second);
        //}
        sort(clr.begin(),clr.end(),cmp);
        /*for(int i=0;i<clr.size();i++){
            printf("%lld %lld\n",clr[i].first,clr[i].second);
        }*/
        printf("%lld ",ans1);
        int en=clr[0].second,ans2=1;
        for(int i=1;i<clr.size();i++){
            //printf("%lld %lld %lld\n",clr[i].first,clr[i].second,en);
            if(clr[i].first>en){
                ans2++;
                en=clr[i].second;
            }
        }
        printf("%lld\n",m-ans2);
    }
    return 0;
}